namespace KinonekoSoftware.CodariaDB.Documents.Templates
{
    public sealed class DataPartTypeSelector : ObservableObject
    {
        private bool _isSelected;

        public void ClearSelection()
        {
            SetValue(ref _isSelected, false, nameof(IsSelected));
        }

        public required string                       Name                { get; init; }
        public required string                       Category            { get; init; }
        public required string                       Mutex               { get; init; }
        public required string                       Icon                { get; init; }
        public required DataPartType                 Type                { get; init; }
        public          DataPartTypeSelectionHandler ValueChangedHandler { get; set; }

        /// <summary>
        /// 获取或设置 <see cref="IsSelected"/> 属性。
        /// </summary>
        public bool IsSelected
        {
            get => _isSelected;
            set
            {
                ValueChangedHandler?.Invoke(this, value, Mutex);
                SetValue(ref _isSelected, value);
            }
        }
    }
}